package com.lizanyi.teaFriend.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lizanyi.teaFriend.mapper.GoodsMapper;
import com.lizanyi.teaFriend.pojo.Goods;
import com.lizanyi.teaFriend.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceimpl implements GoodsService {
    @Autowired
    private GoodsMapper goodsMapper;


    @Override
    public Goods getGoodsListBygid(Integer gid) {

        Goods good =goodsMapper.selectByPrimaryKey(gid);
        System.out.println(good);
        return good;
    }

    @Override
    public int updateGoodById(Integer gid,String gname,Double price,Integer num) {
        int update = goodsMapper.updateByPrimaryKeySelective(new Goods(gid,gname,price,num));
        return update;
    }

    @Override
    public int deleteGoodById(Integer id) {
        int flag=goodsMapper.deleteByPrimaryKey(id);
        return flag;
    }

    @Override
    public int addGood(Integer gid, String gname, Double price, Integer num) {
       int flag=goodsMapper.insertSelective(new Goods(gid,gname,price,num,"1"));
        return flag;
    }


}
